package cn.lds.j368.dsbank.controller;

import cn.lds.j368.dsbank.annotation.SysLogAnnotation;
import cn.lds.j368.dsbank.domain.Employee;
import cn.lds.j368.dsbank.domain.LoanApply;
import cn.lds.j368.dsbank.exception.ServiceException;
import cn.lds.j368.dsbank.service.LoanApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Conditional;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;

@Controller
@RequestMapping("loan_assess")
public class LoanAssessController {

    @Autowired
    private LoanApplyService loanApplyService;

    @PostMapping("/loan_assess")
    @SysLogAnnotation(operUrl = "/loan_assess/loan_assess",operModul = "/loan_assess",operType = "添加",operDesc = "审批")
    public String loanAssess(LoanApply loanApply, @AuthenticationPrincipal Employee employee) throws ServiceException {

        //我们测试添加审核人id
        loanApply.setApprovalEmpId(employee.getEmpId());

        loanApply.setApprovalTime(new Date());

        loanApplyService.addOrModifyLoanApply(loanApply);

        return "redirect:/loan/show_loans_apply";

    }
}
